#!/bin/bash
#
#chkconfig: - 55 45
#config: /etc/sysconfig/memcached
#source function library
. /etc/rc.d/init.d/functions

PORT=12001
USER=nobody
MAXCONN=1024
CACHESIZE=1024
OPTION=""
if [ -f /etc/sysconfig/memcached ];then
	. /etc/sysconfig/memcached
fi
if [ "$NETWORKING" == "no" ];then
	exit 0
fi
retval=0
prog="memcached"
function start() {
	echo -n $"starting $prog:"
	chown $USER /var/run/memcached
	daemon /usr/local/memcached-1.4.35/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -p /var/run/memcached.pid $OPTIONS
	echo
	retval=$?
	[ $retval -eq 0 ] && touch /var/lock/subsys/memcached

}
function stop() {

	echo -n $"stopping $prog:"
	killproc memcached
	echo
	retval=$?
	if [ $retval -eq 0 ];then
		rm -f /var/lock/subsys/memcached
		rm -f /var/run/memcached.pid
	fi
}
function restart() {
	stop
	start
}
case $1 in
start)
	start
	;;
stop)
	stop
	;;
restart)
	restart
	;;
status)
	status memcached
	;;
*)
	echo $"Usage: $0 <start|stop|restart|status>"
esac


